#include "cusproxymodel.h"
#include "cuslistmodel.h"

CusProxyModel::CusProxyModel(QObject *parent) : QSortFilterProxyModel(parent)
{

}

void CusProxyModel::filterByState(int state)
{
    QRegExp::PatternSyntax syntax = QRegExp::PatternSyntax(1);//E_PrinterState对应的role是1
    Qt::CaseSensitivity caseSensitivity = Qt::CaseSensitive;
    QRegExp regExp(0, caseSensitivity, syntax);
    this->setFilterRegExp(regExp);
}

void CusProxyModel::filterByGroup(const QString &groupName)
{
    QRegExp::PatternSyntax syntax =QRegExp::PatternSyntax(14);//E_GroupNo对应的role是14
    Qt::CaseSensitivity caseSensitivity = Qt::CaseSensitive;
    QRegExp regExp(groupName, caseSensitivity, syntax);
    this->setFilterRegExp(regExp);
}

QAbstractItemModel *CusProxyModel::cSourceModel() const
{
    return m_cSourceModel;
}

void CusProxyModel::setCSourceModel(QAbstractItemModel *newCSourceModel)
{
    if (m_cSourceModel == newCSourceModel)
        return;
    m_cSourceModel = newCSourceModel;
}

void CusProxyModel::setSourceModel(QAbstractItemModel *sourceModel)
{
    QSortFilterProxyModel::setSourceModel(sourceModel);
    m_cSourceModel = sourceModel;
}
